

$(function(){
    //发送ajax获取用户信息并且渲染到页面
    $.ajax({
        url:"admin/user/detail",
        type:"get",
        success:function(res){
            $(`#inputEmail1`).val(res.data.username)
            $(`#inputEmail2`).val(res.data.nickname)
            $(`#inputEmail3`).val(res.data.email)
            $(`.user_pic`).attr(`src`,res.data.userPic)
            $(`#inputEmail4`).val(res.data.password)
            console.log(res)
        }
    })
    // 选择要换的图片显示到对应的地方
    $(`#exampleInputFile`).on(`change`,function(){
        let aa=this.files[0]
        let url=URL.createObjectURL(aa)
        console.log(url)
        $(`#pic`).attr(`src`,url)

    })
    // 点击修改信息
    $(`.btn-edit`).on(`click`,function(e){
        e.preventDefault()
        let data=new FormData($(`form`)[0])
        $.ajax({
            url:"admin/user/edit",
            type:"post",
            data:data,
            contentType:false,
            processData:false,
            success:function(res){
                if(res.code==200){
                    // alert(res.msg)
                    // window.location.reload()
                    // window.parent.$("iframe").attr(`src`,`./index.html`)
                    layer.msg(res.msg,{time:2000},()=>{
                    window.location.href="./main_count.html"

                    })
                }else{
                    layer.msg(res.msg)
                }
            }
        })
    })
})